Ext.define('PJ.view.ministriesmanagement.Edit', {
	extend: 'AM.default.DefaultWindowForm',
	alias: ['widget.msgEdit'],
	requires: ['AM.default.DefaultDateField', 
	           'AM.default.DateTime',
	           'AM.default.jsonp.DefaultSubmitJsonp',
	           'AM.default.DefaultDateField'],

	modal: true,// 开启不允许点击其他组件
	frame: true,
	notEdit: true,
	layout: 'form',
	isSame: false,
	autoHeight: true,

	initComponent: function(){
    	var me = this;
    	var bt = '<span style="color:red;">*</span>';
    	me.items= [{
    		defaults: {
    			labelAlign: 'right',
    			labelWidth: 190,
    			columnWidth: .5,
    			padding:"5 0 0 0",
    			readOnly:me.isView
    		},
    		border: false,
    		xtype: "container",
    		width: 300,
    		layout: 'column',
    		items: [{
            	xtype: 'numberfield',
                fieldLabel: bt+'请输入要增加部委管理员的数量',
                name: 'userNumber',
	            allowBlank: false,
	            readOnly:false,
	            columnWidth: 1,
	            allowDecimals: false,
	            minValue: 1,
	            hideTrigger: true
            }]
    	}];
    	this.buttons = [{
            text: '确定',
            handler: function(button, event){
                var win = button.up('window');
                win.sub();
            }
        }, {
            text: '取消',
            scope: this,
            handler: this.close
        }];
		this.callParent(arguments);
	},
    sub:function(){
		var win = this;
		var form = win.down('form');
		var baseForm = form.getForm();
		if (!baseForm.isValid()) {
			return;
		}
		var url =win.grid.store.addUrl;
		if(gj_onlineLearning_constant.loadType == "jsonp"){
			baseForm.doAction('submitJsonp',{
				url: url,
				params:{
					depId:win.classId
					//userNumber:2,
					//searchDepCode:421,
					//depId:7501
				},
				success: function(f, action){
					if (action.result.success) {
						Ext.Msg.alert('消息', "操作成功!", function(){
							var gridPanel = win.grid;
							var store = gridPanel.getStore();
							store.reload();
							win.close();
						});
					}else{
						Ext.Msg.alert('消息', action.result.msg||"系统出错,请联系管理员!", function(){
							win.close();
						});
					}
				},
				failure: function(f, action){
					if (action.result) {
						Ext.Msg.alert('错误', action.result.msg||"系统出错,请联系管理员!");
					}
					else {
						Ext.Msg.alert('错误', action.result.msg||"系统出错,请联系管理员!");
					}
				}
			});
		}else{
			baseForm.submit({
				url: url,
				params:{
					depId:win.classId
				},
				success: function(f, action){
					if (action.result.success) {
						Ext.Msg.alert('消息', "操作成功!", function(){
							var gridPanel = win.grid;
							var store = gridPanel.getStore();
							store.reload();
							win.close();
						});
					}else{
						Ext.Msg.alert('消息', action.result.msg||"系统出错,请联系管理员!", function(){
							win.close();
						});
					}
				},
				failure: function(f, action){
					if (action.result) {
						Ext.Msg.alert('错误', action.result.msg||"系统出错,请联系管理员!");
					}
					else {
						Ext.Msg.alert('错误', "系统出错,请联系管理员!");
					}
				}
			});
		}
	
    }
});